<template>
  <uni-list>
    <uni-list-item
      v-for="item in options"
      :title="item.label"
      :note="detailData[item.prop]"
    >
    </uni-list-item>
    <uni-list-item
      title="排查结果"
      v-if="detailData.checkResult"
      :note="detailData.checkResult"
    >
    </uni-list-item>
  </uni-list>
</template>
<script>
export default {
  data() {
    return {
      row: {},
      options: [
        {
          label: "所属部门",
          prop: "deptName",
        },
        {
          label: "装置名称",
          prop: "deviceName",
        },
        {
          label: "单元名称",
          prop: "analysisUnit",
        },
        {
          label: "风险事件",
          prop: "dangerEvent",
        },
        {
          label: "排查内容",
          prop: "hiddenContent",
        },
        {
          label: "周期",
          prop: "cycle",
        },
        {
          label: "周期单位",
          prop: "unit",
        },
        {
          label: "人员配置",
          prop: "checkUserNames",
        },
        {
          label: "任务开始时间",
          prop: "startTime",
        },
        {
          label: "任务结束时间",
          prop: "endTime",
        },
        {
          label: "排查状态",
          prop: "taskState",
        },
      ],
      id: null,
    };
  },
  onLoad(payload) {
    if (payload.row) {
      this.row = JSON.parse(decodeURIComponent(payload.row));
    }
    if (payload.id) {
      this.id = payload.id;
    }
  },
};
</script>
<script setup>
import { apis } from "@/api/yhpc/pcrw.js";
import { router } from "@/router/index.js";
import { ref, onMounted, getCurrentInstance } from "vue";
const onSubmit = (checkResult, id) => {
  if (checkResult) {
    apis
      .updateTaskState({
        checkResult,
        id,
      })
      .then((res) => {
        router.back();
      });
  } else {
    uni.showToast({
      title: "请填写排查结果",
      icon: "error",
    });
    return false;
  }
};
const checkResult = ref();
const detailData = ref({});
onMounted(() => {
  const { id, row } = getCurrentInstance().data;
  if (id) {
    apis.detail(id).then((res) => {
      detailData.value = res.data;
    });
  } else {
    detailData.value = row;
  }
});
</script>

<style lang="scss" scoped></style>
